#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Solution
{
public:
    string arr[10] = { "","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
    vector<string> ret;
    string path;

    vector<string> letterCombinations(string digits)
    {
        if (digits == "") return ret;
        dfs(digits, 0);
        return ret;
    }

    void dfs(string& digits, int pos)
    {
        if (pos == digits.size())
        {
            ret.push_back(path);
            return;
        }

        int num = digits[pos] - '0';
        string str = arr[num];
        for (int i = 0; i < str.size(); i++)
        {
            path.push_back(str[i]);
            dfs(digits, pos + 1);
            path.pop_back();
        }
    }
};